package  
{
	import flash.media.SoundChannel;
	import flash.events.Event;
	/**
	 * ...
	 * @author Miles
	 */
	public class SoundMan 
	{
		private var SndList:Array;
		
		public function SoundMan() 
		{
			SndList = new Array();
		}
		
		public function addSound(snd:Object, play:Boolean = false):int {
			var _sndChannel:SoundChannel = new SoundChannel();
			_sndChannel = snd.play();
			
			SndList.push(_sndChannel);
			//playMusic(SndList.length - 1);
			
			return SndList.length-1;
		}
//
		//public function playMusic(index:int):void
		//{
			//SndList[index] = music.play();
			//musicChannel.addEventListener(Event.SOUND_COMPLETE, loopMusic);
		//}
//
		//public function loopMusic(e:Event):void
		//{
			//if (musicChannel != null)
			//{
				//musicChannel.removeEventListener(Event.SOUND_COMPLETE, loopBackgroundMusic);
			//playMusic();
			//}
		//}
		
		public function stopSnd(index:int):void {
			SndList[index].stop();
		}
		
		public function stopAll():void {
			for each (var snd:SoundChannel in SndList)
			{
				snd.stop();
			}
		}
		
		public function removeAll():void {
			SndList = new Array();
		}
		
	}

}